
const app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    currentData:0,
    lfdappointlist:[],
    len:0,
    status: 0,    // 确定到店 status=0 ，确定完成 1，去评价 2，已完成 3,
    // Height:'',
    // len:0,  //订单长度
  },
  
  // 点击选项卡切换，滑块index赋值
   checkCurrent:function(e){
    console.log("点击导航",e)
    console.log("导航栏索引值：",e.currentTarget.dataset.current)
    console.log("导航栏状态值：",e.currentTarget.dataset.status)
    const that = this;
    if(that.data.currentData===e.currentTarget.dataset.current){
      return false;
    }else{
       that.setData({
         currentData:e.currentTarget.dataset.current,
         status:e.currentTarget.dataset.status
       })
    }
  },
  bindchange:function(e){
    const that  = this;
    var tabsnums = e.detail.current
    that.setData({
      currentData:e.detail.current
    })
  },
  backlfd:function(e){
    var sid = e.currentTarget.dataset.sid;
    wx.navigateTo({
      url: '../appointments/appointments?id=' + sid ,
    })
  },
  //  swiperHeight:function(e){
  //   var winWid = wx.getSystemInfoSync().windowHeight;
  //   this.setData({
  //     Height : winWid
  //   })
  //  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (e) {

    var that = this;
    wx.request({
      url: app.globalData.headurl + '/Lfdappoint/selectLfdappointByOpenid',
      data: {
        openid: app.globalData.openid
      },
      method: "POST",
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=utf-8",
      },
      success: function (re) {
        that.data.lfdappointlist = re.data
        console.log("订单",that.data.lfdappointlist)
        that.data.len = re.data.length;
        that.setData({
          lfdappointlist: re.data.reverse()
        })
      }
    })
  },


  toupdate: function (e) {
    var that = this;
    var id = e.currentTarget.dataset.id;
    var status = e.currentTarget.dataset.status;
    console.log("id:"+id+" status:"+status)
    wx.request({
      url: app.globalData.headurl + '/Lfdappoint/updateLfdappoint',
      data: {
        id: id,
        status:status
      },
      method: "POST",
      header: {
        "content-type": "application/x-www-form-urlencoded;charset=utf-8",
        //token: app.globalData.token
      },
      success: function (re) {
        wx.showToast({
          title: '操作成功',
        })
        that.onLoad();

      }
    })

  },

  tocomment: function (e) {
    var that = this;
    var id = e.currentTarget.dataset.id;
    var lid = e.currentTarget.dataset.lid;
    wx.navigateTo({
      url: '../comment/index?id=' + id + '&lid=' + lid,
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.onLoad();
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})